package slot_game

import (
	"gitee.com/liuxuezhan/ar-platform/assets-rpc/rpc"
	"github.com/spf13/cast"
	"gorm.io/gorm"
)

func ShardByUserID(TableName string, userID int) func(db *gorm.DB) *gorm.DB {
	return func(db *gorm.DB) *gorm.DB {
		tableName := TableName + "_" + cast.ToString(userID%10)
		return db.Table(tableName)
	}
}

type SlotHistory struct {
	rpc.DataHead      `gorm:"embedded"`
	DeletedAt         gorm.DeletedAt `gorm:"index"`
	rpc.SlotsGameData `gorm:"embedded"`
}

func (*SlotHistory) TableName() string {
	return "t_SlotLog"
}

type SlotGame struct {
	rpc.DataHead      `gorm:"embedded"`
	DeletedAt         gorm.DeletedAt `gorm:"index"`
	rpc.SlotsGameData `gorm:"embedded"`
}

func (*SlotGame) TableName() string {
	return "t_SlotGame"
}
